<html>
<head><meta charset="utf-8"><title>splitting Unevaluated · t-compiler/const-eval · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/index.html">t-compiler/const-eval</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html">splitting Unevaluated</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="217677525"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/217677525" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#217677525">(Nov 23 2020 at 20:14)</a>:</h4>
<p>I think that at least some places get a bit cleaner when splitting <code>ConstKind::Unevaluated</code> into <code>Unevaluated</code> and <code>Promoted</code> or something instead of using <code>Unevaluated</code> for both. I would like to try splitting these. </p>
<p>Does one of you have a preference here? cc <span class="user-mention" data-user-id="124288">@oli</span> <span class="user-mention" data-user-id="121053">@varkor</span></p>



<a name="217677614"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/217677614" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#217677614">(Nov 23 2020 at 20:15)</a>:</h4>
<p>imo the difference between promoteds and other unevaluated anon consts is quite big</p>



<a name="217684840"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/217684840" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#217684840">(Nov 23 2020 at 21:26)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/splitting.20Unevaluated/near/217677614">said</a>:</p>
<blockquote>
<p>imo the difference between promoteds and other unevaluated anon consts is quite big</p>
</blockquote>
<p>that's in itself something we should fix, not adjust the rest of the compiler around</p>



<a name="217684897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/217684897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#217684897">(Nov 23 2020 at 21:27)</a>:</h4>
<p>also see <a href="#narrow/stream/213817-t-lang/topic/Promotion.20RFC.20draft">this WIP RFC draft</a></p>



<a name="217684979"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/217684979" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#217684979">(Nov 23 2020 at 21:28)</a>:</h4>
<p>doesn't your WIP draft increase the difference</p>



<a name="217685017"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/217685017" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#217685017">(Nov 23 2020 at 21:28)</a>:</h4>
<p>afaik promoteds do not participate in typeck and can't fail evaluation</p>



<a name="217685053"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/217685053" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#217685053">(Nov 23 2020 at 21:29)</a>:</h4>
<p>they are also accessed in a different way to other constants by using <code>promoted_mir</code></p>



<a name="217685428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/217685428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#217685428">(Nov 23 2020 at 21:33)</a>:</h4>
<p>re the wip draft, i think we could add and promote <code>CheckedDiv</code> and <code>CheckedMod</code> so we don't break <code>&amp;(1 % 2)</code></p>



<a name="217685450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/217685450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#217685450">(Nov 23 2020 at 21:33)</a>:</h4>
<p>i think i already wanted to do something similar while working on <code>AbstractConst</code>s</p>



<a name="218120202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218120202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218120202">(Nov 27 2020 at 18:49)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/splitting.20Unevaluated/near/217684979">said</a>:</p>
<blockquote>
<p>doesn't your WIP draft increase the difference</p>
</blockquote>
<p>how that? currently the difference is that promoteds can fail to evaluate. at least all cases that I have seen where promoteds need special-casing were due to that. you might be talking about other special cases.</p>



<a name="218120282"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218120282" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218120282">(Nov 27 2020 at 18:50)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/splitting.20Unevaluated/near/217685428">said</a>:</p>
<blockquote>
<p>re the wip draft, i think we could add and promote <code>CheckedDiv</code> and <code>CheckedMod</code> so we don't break <code>&amp;(1 % 2)</code></p>
</blockquote>
<p>not breaking that is easy, we can just check the RHS and if it is a non-0 literal, accept the division. <code>&amp;(1 % (1+1))</code> is harder as we'd have to evaluate the RHS, which I don't think we want to do. if we truly need this then indeed we should go for <code>CheckedMod</code> I think.</p>



<a name="218121408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218121408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218121408">(Nov 27 2020 at 19:06)</a>:</h4>
<p><code>1 / N</code> where <code>N</code> is a const param</p>



<a name="218156798"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218156798" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218156798">(Nov 28 2020 at 09:44)</a>:</h4>
<p>yes and that. my hope is that that doesnt happen in practice so we do not have to support it.^^</p>



<a name="218933504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218933504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218933504">(Dec 05 2020 at 12:36)</a>:</h4>
<p><span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>
<p>i experimented a bit with pretty much moving promoteds out of <code>ty::Const</code> entirely and instead using an enum in <code>mir::Constant</code> and it seems fairly promising to me</p>



<a name="218933513"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218933513" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218933513">(Dec 05 2020 at 12:36)</a>:</h4>
<p>it makes dealing with <code>Constant</code>s a bit less pleasant in mir, though it also makes it more clear what's going on everywhere</p>



<a name="218933523"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218933523" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218933523">(Dec 05 2020 at 12:37)</a>:</h4>
<p>but imo it does noticeably improve interacting with consts in the type system</p>



<a name="218933570"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218933570" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218933570">(Dec 05 2020 at 12:38)</a>:</h4>
<p>will probably experiment a bit more and then open a draft PR and an MCP</p>



<a name="218935469"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218935469" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218935469">(Dec 05 2020 at 13:34)</a>:</h4>
<p>I remain opposed to this. Promoteds should be made <em>more</em> like other consts, not less like them. The more we have to make them a special case, the more something is wrong.</p>



<a name="218935473"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218935473" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218935473">(Dec 05 2020 at 13:35)</a>:</h4>
<p>Could you please give an example for where this is helpful? So far I don't think I have seen one that would not be fixed by my RFC.</p>



<a name="218980176"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218980176" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218980176">(Dec 06 2020 at 10:27)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/splitting.20Unevaluated/near/218933504">said</a>:</p>
<blockquote>
<p>i experimented a bit with pretty much moving promoteds out of <code>ty::Const</code> entirely and instead using an enum in <code>mir::Constant</code> and it seems fairly promising to me</p>
</blockquote>
<p>btw, we (<span class="user-mention" data-user-id="124288">@oli</span> and me) have some plans to fairly fundamentally refactor all of this using valtrees, also to help const generics. my notes on this <a href="https://hackmd.io/Qvrj_eOFTkCHZrhJ7f1ItA">can be found here</a>. I am not sure how what you said above fits into that plan.</p>



<a name="218980888"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218980888" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218980888">(Dec 06 2020 at 10:47)</a>:</h4>
<p>it would fit in fairly well</p>



<a name="218980935"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218980935" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218980935">(Dec 06 2020 at 10:48)</a>:</h4>
<p>i think, so afaict you want to pretty much use <code>mir::Const</code> inside of <code>mir::Operand</code>?</p>



<a name="218980941"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218980941" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218980941">(Dec 06 2020 at 10:48)</a>:</h4>
<p>this is the only place where promoted can exist as well</p>



<a name="218980957"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218980957" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218980957">(Dec 06 2020 at 10:49)</a>:</h4>
<p>so we would end up using</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="k">enum</span> <span class="nc">LazyConst</span><span class="o">&lt;</span><span class="n">T</span><span class="p">,</span><span class="w"> </span><span class="n">P</span><span class="o">&gt;</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="n">Param</span><span class="p">(</span><span class="o">..</span><span class="p">.),</span><span class="w"></span>
<span class="w">    </span><span class="n">Infer</span><span class="p">(</span><span class="o">..</span><span class="p">.),</span><span class="w"></span>
<span class="w">    </span><span class="n">Bound</span><span class="p">(</span><span class="o">..</span><span class="p">.),</span><span class="w"></span>
<span class="w">    </span><span class="n">Placeholder</span><span class="p">(</span><span class="o">..</span><span class="p">.),</span><span class="w"></span>
<span class="w">    </span><span class="n">Unevaluated</span><span class="p">(</span><span class="n">def</span><span class="p">,</span><span class="w"> </span><span class="n">substs</span><span class="p">),</span><span class="w"></span>
<span class="w">    </span><span class="n">Promoted</span><span class="p">(</span><span class="n">def</span><span class="p">,</span><span class="w"> </span><span class="n">substs</span><span class="p">,</span><span class="w"> </span><span class="n">P</span><span class="p">),</span><span class="w"></span>
<span class="w">    </span><span class="n">Evaluated</span><span class="p">(</span><span class="n">T</span><span class="p">),</span><span class="w"></span>
<span class="w">    </span><span class="n">Error</span><span class="p">(</span><span class="o">..</span><span class="p">.),</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="218980959"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218980959" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218980959">(Dec 06 2020 at 10:49)</a>:</h4>
<p>with <code>mir::Const</code> using <code>P = Promoted</code></p>



<a name="218981007"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218981007" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218981007">(Dec 06 2020 at 10:50)</a>:</h4>
<p>and <code>ty::Const</code> using <code>P = !</code> with allows us to completely ignore the <code>Promoted</code> variant when using <code>feature(exhaustive_patterns)</code></p>



<a name="218981026"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218981026" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218981026">(Dec 06 2020 at 10:51)</a>:</h4>
<p>i think we could even remove <code>Infer</code> variant for <code>mir::Const</code> this way as that shouldn't exist</p>



<a name="218981876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218981876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218981876">(Dec 06 2020 at 11:12)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/splitting.20Unevaluated/near/218980935">said</a>:</p>
<blockquote>
<p>i think, so afaict you want to pretty much use <code>mir::Const</code> inside of <code>mir::Operand</code>?</p>
</blockquote>
<p>yes. going through a <code>ty</code> type there conceptually makes little sense anyway.</p>



<a name="218981896"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218981896" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218981896">(Dec 06 2020 at 11:13)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/splitting.20Unevaluated/near/218981007">said</a>:</p>
<blockquote>
<p>and <code>ty::Const</code> using <code>P = !</code> with allows us to completely ignore the <code>Promoted</code> variant when using <code>feature(exhaustive_patterns)</code></p>
</blockquote>
<p>so which problems is this solving? I assume whatever it is that <code>Unevaluated</code> takes as argument can be an opaque type "identifying a constant (any constant, promoted or not)" and then there is a way to evaluate any such identified constant. With that being the case, it just shouldn't matter whether this is a promoted or not?</p>



<a name="218981967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218981967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218981967">(Dec 06 2020 at 11:15)</a>:</h4>
<p>The only <code>ty::Const</code> which can be promoted are the ones used in <code>mir::Operand</code></p>



<a name="218981970"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218981970" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218981970">(Dec 06 2020 at 11:15)</a>:</h4>
<p>you cannot have a type which contains a promoted constant</p>



<a name="218982016"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982016" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982016">(Dec 06 2020 at 11:16)</a>:</h4>
<blockquote>
<p>so which problems is this solving?</p>
</blockquote>
<p>that there are no <code>ty::Const</code> which contain a promoted</p>



<a name="218982020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982020">(Dec 06 2020 at 11:16)</a>:</h4>
<p>so it's currently always <code>None</code></p>



<a name="218982028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982028">(Dec 06 2020 at 11:17)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/splitting.20Unevaluated/near/218982020">said</a>:</p>
<blockquote>
<p>so it's currently always <code>None</code></p>
</blockquote>
<p>it = what?</p>



<a name="218982029"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982029" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982029">(Dec 06 2020 at 11:17)</a>:</h4>
<p><code>ty::Const</code></p>



<a name="218982035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982035">(Dec 06 2020 at 11:17)</a>:</h4>
<p><code>ty::Const</code> is <code>None</code>?</p>



<a name="218982037"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982037" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982037">(Dec 06 2020 at 11:17)</a>:</h4>
<p>for <code>ty::Const</code> once we added <code>mir::Const</code> the <code>Option&lt;Promoted&gt;</code> of <code>ConstKInd::Unevaluated</code> would always be none</p>



<a name="218982038"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982038" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982038">(Dec 06 2020 at 11:17)</a>:</h4>
<p>I assume you refer to this?</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="n">Unevaluated</span><span class="p">(</span><span class="n">WithOptConstParam</span><span class="o">&lt;</span><span class="n">DefId</span><span class="o">&gt;</span><span class="p">,</span><span class="w"> </span><span class="n">SubstsRef</span><span class="o">&lt;'</span><span class="na">tcx</span><span class="o">&gt;</span><span class="p">,</span><span class="w"> </span><span class="nb">Option</span><span class="o">&lt;</span><span class="n">Promoted</span><span class="o">&gt;</span><span class="p">)</span><span class="w"></span>
</code></pre></div>



<a name="218982043"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982043" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982043">(Dec 06 2020 at 11:18)</a>:</h4>
<p>yes</p>



<a name="218982081"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982081" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982081">(Dec 06 2020 at 11:18)</a>:</h4>
<p>so what I am proposing is to replace this by</p>
<div class="codehilite" data-code-language="Rust"><pre><span></span><code><span class="n">Unevaluated</span><span class="p">(</span><span class="n">ConstId</span><span class="p">,</span><span class="w"> </span><span class="n">SubstsRef</span><span class="o">&lt;'</span><span class="na">tcx</span><span class="o">&gt;</span><span class="p">)</span><span class="w"></span>
</code></pre></div>



<a name="218982082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982082">(Dec 06 2020 at 11:18)</a>:</h4>
<p>yeah</p>



<a name="218982087"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982087" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982087">(Dec 06 2020 at 11:18)</a>:</h4>
<p>where <code>ConstId</code> is its own abstraction and nboody in the outside world cares if there even exists a <code>promoted</code> field</p>



<a name="218982088"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982088" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982088">(Dec 06 2020 at 11:18)</a>:</h4>
<p>no, <code>Unevaluated(WithOptConstParam&lt;DefId&gt;, SubstsRef&lt;'tcx&gt;)</code></p>



<a name="218982090"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982090" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982090">(Dec 06 2020 at 11:19)</a>:</h4>
<p>there are no promoteds inside of types</p>



<a name="218982094"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982094" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982094">(Dec 06 2020 at 11:19)</a>:</h4>
<p>right so what?</p>



<a name="218982096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982096">(Dec 06 2020 at 11:19)</a>:</h4>
<p>and then there are functions to say "please give me the result of evaluating that <code>ConstId</code>"</p>



<a name="218982103"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982103" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982103">(Dec 06 2020 at 11:19)</a>:</h4>
<p>IOW, I agree types shouldnt have to care about that promoteds field. but I think your approach is not the right one to achieve this.</p>



<a name="218982107"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982107" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982107">(Dec 06 2020 at 11:19)</a>:</h4>
<p>note that I wrote above is "what <em>I</em> am proposing"</p>



<a name="218982119"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982119" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982119">(Dec 06 2020 at 11:20)</a>:</h4>
<p>I didnt claim his to be the same as your proposal</p>



<a name="218982149"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982149" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982149">(Dec 06 2020 at 11:20)</a>:</h4>
<p>misread that <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="218982154"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982154" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982154">(Dec 06 2020 at 11:20)</a>:</h4>
<p>I thought so :D</p>



<a name="218982167"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982167" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982167">(Dec 06 2020 at 11:20)</a>:</h4>
<p>now, this <code>WithOptConstParam</code> stuff makes this even more "interesting"</p>



<a name="218982170"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982170" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982170">(Dec 06 2020 at 11:20)</a>:</h4>
<p>since <code>mir::Constant</code> shouldnt have to care about that, right?</p>



<a name="218982227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982227">(Dec 06 2020 at 11:22)</a>:</h4>
<p>I think so</p>



<a name="218982239"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982239" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982239">(Dec 06 2020 at 11:22)</a>:</h4>
<p>though maybe we do some weird stuff with constants in mir during borrowck or something</p>



<a name="218982251"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982251" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982251">(Dec 06 2020 at 11:23)</a>:</h4>
<p>do we try to evaluate <code>mir::Constant</code>s when optimizing?</p>



<a name="218982254"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982254" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982254">(Dec 06 2020 at 11:23)</a>:</h4>
<p>I see no reason why we wouldnt</p>



<a name="218982256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982256">(Dec 06 2020 at 11:23)</a>:</h4>
<p>then we need <code>WithOptConstParam</code> i think</p>



<a name="218982298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982298">(Dec 06 2020 at 11:24)</a>:</h4>
<p>I dont think so. the type of a <code>mir::Constant</code> should always be known locally.</p>



<a name="218982303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982303">(Dec 06 2020 at 11:24)</a>:</h4>
<p>constants in MIR worked just fine before you added that thing. I consider that constructive evidence that it is not needed. :D</p>



<a name="218982319"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982319" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982319">(Dec 06 2020 at 11:25)</a>:</h4>
<p>we never used const params in type dependent paths before i added that thing</p>



<a name="218982324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982324">(Dec 06 2020 at 11:25)</a>:</h4>
<p>so typeck also worked fine before i added this</p>



<a name="218982328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982328">(Dec 06 2020 at 11:25)</a>:</h4>
<p>but there are no <code>mir::Constant</code> there I think</p>



<a name="218982335"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982335" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982335">(Dec 06 2020 at 11:25)</a>:</h4>
<p>that's true</p>



<a name="218982372"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982372" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982372">(Dec 06 2020 at 11:26)</a>:</h4>
<p>as you said yourself, it's about <em>type</em>-dependent paths</p>



<a name="218982375"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982375" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982375">(Dec 06 2020 at 11:26)</a>:</h4>
<p>IOW, it's about <code>ty::Const</code></p>



<a name="218982377"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982377" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982377">(Dec 06 2020 at 11:26)</a>:</h4>
<p>not <code>mir::Const</code></p>



<a name="218982378"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982378" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982378">(Dec 06 2020 at 11:26)</a>:</h4>
<p>yeah, <code>mir::Constant</code> is fine</p>



<a name="218982381"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982381" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982381">(Dec 06 2020 at 11:26)</a>:</h4>
<p><span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span> thinking is hard</p>



<a name="218982383"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982383" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982383">(Dec 06 2020 at 11:26)</a>:</h4>
<p>so I wonder if it wouldnt make more sense to move the wrapper out, and have <code>WithOptConstParam&lt;ty::Const&gt;</code>...</p>



<a name="218982457"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982457" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982457">(Dec 06 2020 at 11:28)</a>:</h4>
<p>the only alternative I see is to make the <code>LazyConst</code> from my proposal generic not only in the type of the evaluated const but also the type of the "const identifer". but that'll make working on LazyConst generically quite a bit more painful -- now we need a <code>trait ConstId</code> or so to even be able to write functions like "please evaluate that <code>LazyConst</code>"</p>



<a name="218982474"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982474" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982474">(Dec 06 2020 at 11:29)</a>:</h4>
<p>yeah, adding a param to toggle between <code>DefId</code> and <code>WithOptConstParam&lt;DefId&gt;</code> seems like a hastle</p>



<a name="218982534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982534">(Dec 06 2020 at 11:30)</a>:</h4>
<p>though <code>WithOptConstParam</code> feels like something you "have to learn" when dealing with unevaluated constants and they don't really worsen the perf when dealing with <code>ConstKind::Unevaluated</code> so I don't feel too bad about keeping it even for <code>mir::Const</code></p>



<a name="218982536"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218982536" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218982536">(Dec 06 2020 at 11:30)</a>:</h4>
<p><code>ConstKind::Promoted</code> could use a plain <code>DefId</code> though</p>



<a name="218984277"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218984277" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218984277">(Dec 06 2020 at 12:16)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/146212-t-compiler.2Fconst-eval/topic/splitting.20Unevaluated/near/218982474">said</a>:</p>
<blockquote>
<p>yeah, adding a param to toggle between <code>DefId</code> and <code>WithOptConstParam&lt;DefId&gt;</code> seems like a hastle</p>
</blockquote>
<p>well, but it would also provide an alternative way to implement your proposal:<br>
<code>ty::Const = LazyConst&lt;WithOptConstParam&lt;DefId&gt;, Valtree&gt;</code> and<br>
<code>mir::Const = LazyConst&lt;(DefId, Option&lt;Promoted&gt;), ConstVal&gt;</code></p>



<a name="218984284"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/146212-t-compiler/const-eval/topic/splitting%20Unevaluated/near/218984284" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> RalfJ <a href="https://rust-lang.github.io/zulip_archive/stream/146212-t-compiler/const-eval/topic/splitting.20Unevaluated.html#218984284">(Dec 06 2020 at 12:17)</a>:</h4>
<p>I am not sure how well that would work, but I'd prefer this over adding a <code>LazyConst::Promoted</code> variant</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>